{__NOLAYOUT__}
<Widget:show title="上传附件">
    <input class="file-loading" id="uploadAttr" type="file" multiple="true" name="attrs"  >
</Widget:show>

<script type="text/javascript">
$(function(){
    $("#uploadAttr").fileinput({
        'showUpload':true, 
        'multiple':true, 
        'showRemove': true,
        'uploadAsync': false,
        'overwriteInitial': false,
        'uploadUrl': "{$uploadAttrUrl}",
        'previewFileType':'any',

        initialPreview: [
            <volist name="attrs" id="attr">
            "<img onclick=\"openUrl('{$attr.url}')\" style=\"height:160px;cursor: pointer\" src='{$attr.url}'>",
            </volist>
        ],

        initialPreviewConfig: [
            <volist name="attrs" id="attr">
            {caption: "{$attr.title}", width: "120px", url: "{$deleteAttrUrl}&id={$attr.id}", key: {$attr.id}},
            </volist>
        ],
    });
    
    $("#uploadAttr").on('fileuploaded', function(event, params) {
       $.pjax.reload('.page-container');
    });

    $("#uploadAttr").on('filebatchuploadcomplete', function(event, params) {
       $.pjax.reload('.page-container');
    });


       
}) 
function openUrl (url) {
    window.open(url);
}
</script>
